/**
 * @author janet
 * @date 2015-4-30
 */
package net.oscorner.dao.user;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import net.oscorner.commons.BaseDao;
import net.oscorner.entiry.User;


/**
 * @author janet
 * @date 2015-4-30 下午3:58:53
 * 
 */

public class UserDaoImpl implements UserDao{

	private BaseDao baseDao;
	
	public BaseDao getBaseDao() {
		return baseDao;
	}

	public void setBaseDao(BaseDao baseDao) {
		this.baseDao = baseDao;
	}

	@Override
	public boolean checkUser(User user) throws SQLException {
		// TODO Auto-generated method stub
		String strSql = "select count(1) from t_user where userName = ? and password = ? ";
		String []params = {user.getUserName(),user.getPassword()}; 
		int result = baseDao.executeCount(strSql, params);
		if(result == 1)
			return true;
		return false;
	}

	/* (non-Javadoc)
	 * @see net.oscorner.dao.user.UserDao#queryUserList(net.oscorner.entiry.User)
	 */
	@SuppressWarnings("unchecked")
	@Override
	public List<User> queryUserList(User user) throws SQLException {
		// TODO Auto-generated method stub
		String sql = "select * from t_user ";
		List<String> params = new ArrayList<String>();
		List<User> list = baseDao.executeQuery(sql, params.toArray(), user.getClass());
		return list;
	}

}
